﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Network
{
    class HiddenNeural
    {
            /* input  hidden neuronal */
        private double[] ValueInput = new double[4];   //ordre : age:annee:ganglion:seuil
        private double[] Weigth = new double[4];
        //private double seuil = 0.5;
        

        public HiddenNeural()
        {                        
             for (int i=0;i<4;i++)
             {
                 Thread.Sleep(30);
                 Weigth[i] = Math.Round(Utilitaire.GetRandomNumber(-1, 1),2);
             }          
        }
    

        /* Input  */
        public void setInputValue(int in_age,int in_anne,int in_gang)
        {
            ValueInput[0] = in_age;// *0.01;
            ValueInput[1] = in_anne;// *0.01;
            ValueInput[2] = in_gang;// *0.01;
        }

        public double getWeigth(int nb)
        {
            return this.Weigth[nb];
        }
        public void setWeight(int num, double value)
        {
            this.Weigth[num] = value;

        }

        /*  potential */
        public double getPotential()
        {
            double potential_res = ValueInput[0] * Weigth[0] + ValueInput[1] * Weigth[1] + ValueInput[2] * Weigth[2];
            return potential_res;
        }
         
        /* Output  */
        public double getOutput()
        {
            /* output */
            double x = (ValueInput[0] * Weigth[0] + ValueInput[1] * Weigth[1] + ValueInput[2] * Weigth[2] + Weigth[3]);
            
            /* Activation function */
            double output_res = (1.0/(1 + Math.Exp(-x)));
            //double a = (1.0/2.0);
            //System.Console.WriteLine(a);
            return output_res;
        }

    }
}
